﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using AutoFacUtils;
using CashFlow.Db.DAL;
using CashFlow.Db.Entity;
using CashFlow.ShopManage.Def.Models;
using CashFlow.ShopManage.Service;

namespace CashFlow.ShopManage.Service.Implement
{
    public class ShopPerformanceService
        : Service<ShopPerformanceEntity>, IShopPerformanceService
    {
        private IShopService GetShopService() { return AutoFacHelper.Get<IShopService>(); }
        private IShopUserService GetShopUserService() { return AutoFacHelper.Get<IShopUserService>(); }
        private IUserService GetUserService() { return AutoFacHelper.Get<IUserService>(); }

        public IList<ShopPerformanceEntity> QueryByWhere(
            int shopManagerUserId
            , string date)
        {
            using (var db = SqlSugarHelper.GetDb())
            {
                var query = db.Queryable<ShopPerformanceEntity>();

                if (!string.IsNullOrEmpty(date))
                {
                    query = query.Where(x => x.Date == date);
                }

                var ls = query.OrderByDescending(x => x.Date).ToList();
                return ls;
            }
        }
    }
}